﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyFire : MonoBehaviour
{
    public GameObject bullet;

    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(Fire());
    }

    // Update is called once per frame
    void Update()
    {
        //transform.Rotate(0, 0, 2f * Time.deltaTime);
    }

    IEnumerator Fire()
    {
        Vector3 fireDirection = this.transform.right;
        Quaternion startQuaternion = Quaternion.AngleAxis(10, Vector3.forward);

        for(int i = 0; i < 15; i++)
        {
            for(int j = 0; j < 36; j++)
            {
                GameObject temp = Instantiate(bullet);
                temp.transform.position = transform.position;
                temp.transform.rotation = Quaternion.Euler(fireDirection);
                fireDirection = startQuaternion * fireDirection;
            }

            yield return new WaitForSeconds(0.2f);
        }

        yield return null;
    }
}
